//
//  WQSearchView.swift
//  WeiBo
//
//  Created by Xmen on 16/9/20.
//  Copyright © 2016年 111. All rights reserved.
//

import UIKit

class WQSearchView: UIView {

    @IBOutlet weak var rightConstraints: NSLayoutConstraint!

    @IBOutlet weak var searchTextField: WQTextField!

    @IBOutlet weak var searchButton: UIButton!
    
    
    @IBAction func didChanged(_ sender: AnyObject) {
        
        rightConstraints.constant = searchButton.width + 5
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
        }
        
    }
    
    @IBAction func clickBtn(_ sender: AnyObject) {
  
        searchTextField.resignFirstResponder()
        rightConstraints.constant = 0
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
        }
    
    }
    
    //  使用类方法创建xib对象
    class func searchView() -> WQSearchView {
        
        return UINib(nibName: "WQSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as! WQSearchView
    }
    
    
}
